//
//  destinationInterfaceViewController.m
//  INAlienLand
//
//  Created by dllo on 15/6/29.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "destinationInterfaceViewController.h"
#import "HTTPTool.h"
#import "DestCollectionViewCell.h"
#import "destCollectionHeaderReusableView.h"
#import "arerModel.h"
#import "UIImageView+WebCache.h"
#import "hotCityViewController.h"
#import "dataInArr.h"
#import "erveyAreaViewController.h"
#import "searchCollectionViewCell.h"
#import "searchCollectionReusableView.h"
#import "searcchArea.h"
#import "searchCity.h"
#import "nearByViewController.h"
#import "BaseView.h"
#import "destBttonCollectionReusableView.h"
#import "thanksViewController.h"
#import "MJRefresh.h"
#import "MBProgressHUD.h"
#import <AVFoundation/AVFoundation.h>


#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height
@interface destinationInterfaceViewController ()<UICollectionViewDataSource,UICollectionViewDelegate,UISearchBarDelegate>

@property (nonatomic,retain)UISearchBar *seachbar;
@property (nonatomic,retain)NSMutableArray *destSectionArr;
@property (nonatomic,retain)UICollectionView *destCollectionView;
@property (nonatomic,retain)UICollectionView *searchCollectionView;
@property (nonatomic,retain)NSMutableArray *arerArr;
@property (nonatomic,retain)NSMutableArray *arerBigArr;
@property (nonatomic,retain)NSArray *arerSmaArr;
@property (nonatomic,assign)BOOL isSlect;
@property (nonatomic,retain)UIButton *cancelBtn;
@property (nonatomic ,retain)UIImageView *shishi;
@property (nonatomic,retain)NSMutableArray *seachAreaArr;
@property (nonatomic,retain)NSMutableArray *buttonArr;
@property (nonatomic,assign)NSInteger index;
@property (nonatomic,retain)NSMutableArray *buttonsArr;
@property (nonatomic,copy)NSString *Eselect;
@property (nonatomic,copy)NSString *Cselect;
@property (nonatomic,copy)NSString *Aselect;
@property (nonatomic,retain)UILabel *errorlabel;
@property (nonatomic,retain)MBProgressHUD *hud;
@property (nonatomic,assign)BOOL isPlay;
@property (nonatomic,retain)UIButton *stopButton;



@property (nonatomic,retain)NSMutableArray *indexArr;
@end

@implementation destinationInterfaceViewController

-(void)dealloc

{
    [super dealloc];
    [_seachbar release];
    
   [_destCollectionView release];
  [_searchCollectionView release];
    
   [_cancelBtn release];
 [_shishi release];
    
    
}
-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
        
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
        self.buttonsArr = [NSMutableArray array];
    
    // Do any additional setup after loading the view.
//    数组初始化
    self.destSectionArr = [NSMutableArray array];
    self.seachAreaArr = [NSMutableArray array];
  //  self.navigationController.navigationBar.clipsToBounds = YES;
//    设置状态值.根据状态来切换button的title
      self.isSlect = YES;
    
    //解析搜索数据
    
    //创建主页面的collectionview
    [self createView];
    [self greatecollectionview];
    
    //创建seachbar
    [self createseachbar];
    //调用数据解析
    [self createData];
    
    
}
#pragma mark 置顶按钮点击方法
- (void)topButtonClick:(UIButton *)button {
    [self.destCollectionView setContentOffset:CGPointMake(0, 0) animated:YES];
}
//创建search点击的弹出页面
-(void)createView
{
    //创建背景view
   self.shishi = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    self.shishi.backgroundColor = [UIColor blackColor];
    //添加到页面
    [self.view addSubview:self.shishi];
    
    //定义一个FlowLayout
    UICollectionViewFlowLayout *flowlayout =[[UICollectionViewFlowLayout alloc]init];
    //创建flowlayout的尺寸
    flowlayout.itemSize = CGSizeMake((WIDTH-50)/3, 30);
    //collect的滑动方向
    flowlayout.scrollDirection = UICollectionViewScrollDirectionVertical;
    //    flowlayout.minimumInteritemSpacing = 8;
    //    flowlayout.minimumLineSpacing = 8;
    //collect的cell的间距
    flowlayout.sectionInset =UIEdgeInsetsMake(10, 10, 10, 10);
    //将FlowLayout添加到collectviw上
    //创建collection
    self.searchCollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width , HEIGHT) collectionViewLayout:flowlayout];
    self.searchCollectionView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.searchCollectionView];
    //签订collect的协议
    self.searchCollectionView.delegate = self;
    self.searchCollectionView.dataSource = self;
    flowlayout.headerReferenceSize = CGSizeMake(0, 50);
    //对collectviewcell进行注册
    [self.searchCollectionView registerClass:[searchCollectionViewCell class] forCellWithReuseIdentifier:@"searchreuse"];
    //对collectviewheader进行注册
    [self.searchCollectionView registerClass:[searchCollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"searchheader"];
    
    
    
    
    
    
    
//    
}
#pragma mark 创建searchbar
-(void)createseachbar{
//    创建searchbar
    self.seachbar = [[UISearchBar alloc]initWithFrame:CGRectMake(10, 10, WIDTH-100, 30)];
//    [self.navigationController.navigationBar addSubview:seachbar];
    self.navigationItem.titleView = self.seachbar;
    // seachbar.layer.borderWidth = 1;
    self.seachbar.placeholder = @"搜索声音、专辑、人";
    //    seachbar.layer.cornerRadius = 15;
     self.seachbar.tintAdjustmentMode = UIViewTintAdjustmentModeAutomatic;
     self.seachbar.barTintColor = [UIColor whiteColor];
    
    [ self.seachbar setSearchBarStyle:UISearchBarStyleMinimal];
//    seachbar.scopeButtonTitles = [NSArray arrayWithObjects:@"BOY",nil];
     self.seachbar.showsScopeBar =YES;
     //self.seachbar.showsCancelButton= YES;
//    for (UIView *view in [[ self.seachbar.subviews lastObject] subviews]) {
//        if ([view isKindOfClass:[UIButton class]]) {
//            self.cancelBtn = (UIButton *)view;
//            [self buttonTitle];
//            [self.cancelBtn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
//        }
//    }
    //自定义navigationItem的右button
   self.cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
   
    self.cancelBtn.frame = CGRectMake(0, 0, 50, 50);
    [self.cancelBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:self.cancelBtn];
    [self buttonTitle];
    [self.cancelBtn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
//searchbar的协议.点击事件
    self.seachbar.delegate = self;

}
//navigationItem的右button的title的文子
-(void )buttonTitle
{
    //button的title的切换
    if (!self.isSlect) {
        [self.cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
    }else
    {
        [self.cancelBtn setTitle:@"附近" forState:UIControlStateNormal];
    }
    

}
//navigationItem的右button的点击事件
-(void)click:(UIButton *)button
{
    
    if (self.isSlect==YES) {
        //向附近页面跳转
        nearByViewController *nearBy = [[nearByViewController alloc]init];
        [self.navigationController pushViewController:nearBy animated:YES];
        
    }else
    {
        //回首第一响应者
        [ self.seachbar resignFirstResponder];
        self.isSlect =YES;
        [self buttonTitle];
        
        [self.view bringSubviewToFront:self.destCollectionView];
        
        
    }
    
}

//search的点击事件
-(void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
{
    if (self.isSlect) {
        //更改状态值.切换button的文字
        self.isSlect =NO;
        
        
        [self buttonTitle];
        //创建点击弹出的视图
        [self.view bringSubviewToFront:self.searchCollectionView];
        
        
        
    }
}
-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
    
    for (searcchArea *arer in self.seachAreaArr) {
        
        for (arerModel *city in arer.cityArr) {
            
            if ([searchBar.text isEqualToString:city.name]) {
                erveyAreaViewController *areaCity = [[erveyAreaViewController alloc]init];
                
                //属性传值
                areaCity.arer = city;
                [self.navigationController pushViewController:areaCity animated:YES];
                break;
                
            }
        }
    }
    

}
#pragma mark collectviewcell图的点击函数

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    if ([collectionView isEqual:self.destCollectionView]) {
        if (indexPath.section == 0) {
            hotCityViewController *hotcity = [[hotCityViewController alloc]init];
            //                向  hotcity页面跳转
            [self.navigationController pushViewController:hotcity animated:YES];
            dataInArr *dataIn = self.destSectionArr[indexPath.section];
            
            //属性传值
            hotcity.arer = dataIn.dataArer[indexPath.row];
            
        }
        else
        {
            NSLog(@"%ld",indexPath.row);
            erveyAreaViewController *areaCity = [[erveyAreaViewController alloc]init];
            dataInArr *dataIn = self.destSectionArr[indexPath.section];
            
            //属性传值
            
            [self.navigationController pushViewController:areaCity animated:YES];
            areaCity.arer = dataIn.dataArer[indexPath.row];
           
            
        }
        

    }else
    {
        if (indexPath.section ==0) {
            erveyAreaViewController *areaCity = [[erveyAreaViewController alloc]init];
            searcchArea *dataIn = self.seachAreaArr[indexPath.section];
            NSLog(@"%@",dataIn.title);
            
            //属性传值
            areaCity.arer = dataIn.cityArr[indexPath.row];
            [self.navigationController pushViewController:areaCity animated:YES];
        }else
        {
            erveyAreaViewController *areaCity = [[erveyAreaViewController alloc]init];
            searcchArea *dataIn = self.seachAreaArr[indexPath.section];
            NSLog(@"%@",dataIn.title);
            
            //属性传值
            areaCity.arer = dataIn.cityArr[indexPath.row];
            [self.navigationController pushViewController:areaCity animated:YES];
        }
        
    }
    
    
}
/**
 *  创建collectionview
 */
#pragma mark创建主页面collect
-(void)greatecollectionview
{
    //定义一个FlowLayout
    UICollectionViewFlowLayout *flowlayout =[[UICollectionViewFlowLayout alloc]init];
    flowlayout.itemSize = CGSizeMake((WIDTH-30)/2, (WIDTH-20)/2);
    flowlayout.scrollDirection = UICollectionViewScrollDirectionVertical;
//    flowlayout.minimumInteritemSpacing = 8;
//    flowlayout.minimumLineSpacing = 8;
    flowlayout.sectionInset =UIEdgeInsetsMake(10, 10, 10, 10);
    //将FlowLayout添加到collectviw上
   self.destCollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width , HEIGHT-64-49) collectionViewLayout:flowlayout];
    self.destCollectionView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.destCollectionView];
    
    self.destCollectionView.delegate = self;
    self.destCollectionView.dataSource = self;
    flowlayout.headerReferenceSize = CGSizeMake(0, 50);
    //对collectviewcell进行注册
    [self.destCollectionView registerClass:[DestCollectionViewCell class] forCellWithReuseIdentifier:@"reuse"];
    //对collectviewheader进行注册
    [self.destCollectionView registerClass:[destCollectionHeaderReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header"];
    [self.destCollectionView registerClass:[destBttonCollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"buttonheader"];
    
    
}
/**
 *  collectview分区添加title
 *
 *  @param collectionView <#collectionView description#>
 *  @param kind           <#kind description#>
 *  @param indexPath      <#indexPath description#>
 *
 *  @return <#return value description#>
 */
#pragma mark 搭建collect的header
-(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
//    判断collect来创建header
    if ([collectionView isEqual:self.destCollectionView])
    {
//        if (indexPath.section == 2||indexPath.section == 5||indexPath.section == 6) {
//            destBttonCollectionReusableView *destbuttonView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"buttonheader" forIndexPath:indexPath];
//            destbuttonView.backgroundColor = [UIColor whiteColor];
//            
//            
//            dataInArr *datain = self.destSectionArr[indexPath.section];
//            NSString *str =[NSString stringWithFormat:@"%@             >",datain.title] ;
//           [destbuttonView.titlelable setTitle:str forState:UIControlStateNormal] ;
//            [destbuttonView.titlelable addTarget:self action:@selector(detileclick:) forControlEvents:UIControlEventTouchUpInside];
//            
//            // [titlelable removeFromSuperview];
//            
//            
//            return destbuttonView;
//        }else{
        destCollectionHeaderReusableView *destView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header" forIndexPath:indexPath];
        destView.backgroundColor = [UIColor whiteColor];
            /**
             *  默认没有button
             */
            destView.isAdd=NO;
        
        if (indexPath.section == 2||indexPath.section == 5||indexPath.section == 6) {
        
            destView.isAdd=YES;
            if (indexPath.section ==2) {
                [destView.myButton    addTarget:self action:@selector(detileclick2:) forControlEvents:UIControlEventTouchUpInside];
            }else if (indexPath.section ==2) {
                [destView.myButton    addTarget:self action:@selector(detileclick5:) forControlEvents:UIControlEventTouchUpInside];
            }else {
                [destView.myButton    addTarget:self action:@selector(detileclick6:) forControlEvents:UIControlEventTouchUpInside];
            }
           
            
        }
        else
        {
            destView.isAdd=NO;
        }
        
        
    dataInArr *datain = self.destSectionArr[indexPath.section];
   
    destView.titlelable.text =datain.title ;
    
   // [titlelable removeFromSuperview];
    
   
        return destView;
        
    }else
    {
        searchCollectionReusableView *search = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader  withReuseIdentifier:@"searchheader" forIndexPath:indexPath];
        search.backgroundColor = [UIColor colorWithRed:248/255.00 green:246/255.00 blue:230/255.00 alpha:1.000];
        searcchArea *seaArea = self.seachAreaArr[indexPath.section];
        search.titleLable.text =seaArea.title;
        return search;
        
        
    }
    
}
-(void)detileclick2:(UIButton *)button
{
    thanksViewController * thanks = [[thanksViewController alloc]init];
    [self.navigationController pushViewController:thanks animated:YES];
     NSLog(@" [btn superview] =  %@ ",[[button superview]class]);
    thanks.index = @"3";
    [thanks release];

}
-(void)detileclick5:(UIButton *)button
{
        thanksViewController * thanks = [[thanksViewController alloc]init];
        [self.navigationController pushViewController:thanks animated:YES];
         NSLog(@" [btn superview] =  %@ ",[[button superview]class]);
    thanks.index = @"6";
        [thanks release];
    
}
-(void)detileclick6:(UIButton *)button
{
        thanksViewController * thanks = [[thanksViewController alloc]init];
        [self.navigationController pushViewController:thanks animated:YES];
         NSLog(@" [btn superview] =  %@ ",[[button superview]class]);
    thanks.index = @"8";
        [thanks release];
    
}
#pragma mark 分区数两

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{

    //对不同的collect进行分区数的返回控制
    if ([collectionView isEqual:self.destCollectionView]) {
         return self.destSectionArr.count;
    }else{
        return self.seachAreaArr.count;
    }
   
    
}
/**
 *  collectview的协议方法
 *
 *  @param collectionView <#collectionView description#>
 *  @param section        <#section description#>
 *
 *  @return <#return value description#>
 */
#pragma mark 确定cell数
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section

{
//    通过判断来确定应该创建的cell数
    if ([collectionView isEqual:self.destCollectionView]) {
         dataInArr *dataIn = self.destSectionArr[section];
        return dataIn.data.count;

    }
   else
         {
             
             searcchArea *seaArea = self.seachAreaArr[section];
             return seaArea.cityArr.count;
             
         }
    
    
    }
/**
 *  collectview的协议方法
 *
 *  @param collectionView <#collectionView description#>
 *  @param indexPath      <#indexPath description#>
 *
 *  @return <#return value description#>
 */
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    if ([collectionView isEqual:self.destCollectionView]) {
        dataInArr *dataIn = self.destSectionArr[indexPath.section];
        arerModel *arer = dataIn.dataArer[indexPath.row];
        
        
        DestCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse" forIndexPath:indexPath];
        
        [cell.destImage sd_setImageWithURL:[NSURL URLWithString:arer.cover_route_map_cover]];
        
        return cell;
    }else
    {
        searchCollectionViewCell *searchcell =[collectionView dequeueReusableCellWithReuseIdentifier:@"searchreuse" forIndexPath:indexPath];
        searcchArea *seaArea = self.seachAreaArr [indexPath.section];
        arerModel *seaCity = seaArea.cityArr[indexPath.row];
        searchcell.nameLable.text =seaCity.name;
        return searchcell;
    }
    
    
}
    /**
 *  解析数据
 */
-(void)createData
{
    
   
    self.hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
   [self.hud setDimBackground:YES];
    self.hud.labelText = @"加载...";
    [self.hud show:YES];

    //调用封装的第三方
    [HTTPTool get:@"http://api.breadtrip.com/destination/v3/?last_modified_since" body:nil HTTPResult:JSON success:^(id result) {
//        将解析的数据放入字典中
        NSDictionary *dic = result;
        //将解析的数据放入不同的数组
        NSArray *elementsArr = dic[@"elements"];
        NSArray *search_dataArr = dic[@"search_data"];
        //便利数组搭建model
        for (NSDictionary *search_dataDic in search_dataArr) {
            //初始化moderl
            searcchArea *seaArea = [[searcchArea alloc]init];
            //对model的属性赋值
            [seaArea setValuesForKeysWithDictionary:search_dataDic];
            //model装入数组
            [self.seachAreaArr  addObject:seaArea];
            //对model的属性(数组)进行初始化
            seaArea.cityArr = [NSMutableArray array];
            [seaArea release];
            NSArray *arr =search_dataDic[@"elements"];
            for (NSDictionary *elementsDic in arr) {
                //初始化model
                arerModel *seaCity = [[arerModel alloc]init];
                //对model的属性赋值
                [seaCity setValuesForKeysWithDictionary:elementsDic];
                //对model的属性(数组)进行初始化
                [seaArea.cityArr addObject:seaCity];
                [seaCity release];
            }
            
            
        }
        for (NSDictionary *tempDic in elementsArr) {
            
            dataInArr *dataIn = [[dataInArr alloc]init];
            [dataIn setValuesForKeysWithDictionary:tempDic];
            [self.destSectionArr addObject:dataIn];
            NSArray *dataArr = tempDic[@"data"];
            dataIn.dataArer=[NSMutableArray array];
            for (NSDictionary *tempDataDic in dataArr) {
                arerModel *arer = [[arerModel alloc]init];
                [arer setValuesForKeysWithDictionary:tempDataDic];
                [dataIn.dataArer addObject:arer];
                NSDictionary *locaion = tempDataDic[@"location"];
                arer.x = locaion[@"lat"];
                arer.y = locaion[@"lng"];
                
                
            }
            
            [self.indexArr addObject:self.arerArr];
                        [self.arerArr removeAllObjects];
            
        }
        
        
        [self.destCollectionView reloadData];
        
        [self.searchCollectionView reloadData];
        //layer负责显示控件中的一些设置信息,比如边框,弧度等
        //创建一个动画的效果
        CATransition *transistio = [CATransition animation];
        //设置动画的类型
        transistio.type = @"fromTop";
        
        //    suckEffect（三角）
        //
        //    rippleEffect（水波抖动）
        //
        //    pageCurl（上翻页）
        //
        //    pageUnCurl（下翻页）
        //
        //    oglFlip（上下翻转）
        
        //设置动画的时长
        
        [transistio setDuration:3];
        //设置动画的重复次数
        [transistio setRepeatCount:1];
        
        //向imageview的layer里添加动画效果
        [self.searchCollectionView.layer addAnimation:transistio forKey:@"rippleEffect"];
        
#pragma mark 置顶按钮
        UIButton *topButton = [UIButton buttonWithType:UIButtonTypeSystem];
        topButton.frame = CGRectMake(self.view.frame.size.width - 60, self.view.frame.size.height - 60, 35, 35);
        [self.view addSubview:topButton];
        topButton.layer.cornerRadius = 17.5;
        topButton.clipsToBounds = YES;
        topButton.backgroundColor = [UIColor redColor];
        topButton.titleLabel.textColor = [UIColor blackColor];
        [topButton setTitle:@"Top" forState:UIControlStateNormal];
        [topButton addTarget:self action:@selector(topButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        
        
        
       self.stopButton = [UIButton buttonWithType:UIButtonTypeSystem];
        self.stopButton.frame = CGRectMake(25, self.view.frame.size.height - 60, 35, 35);
        [self.view addSubview:self.stopButton];
        self.stopButton.layer.cornerRadius = 17.5;
        self.stopButton.clipsToBounds = YES;
        self.stopButton.backgroundColor = [UIColor redColor];
        self.stopButton.titleLabel.textColor = [UIColor blackColor];
        self.isPlay = YES;
        [self.stopButton setImage:[UIImage imageNamed:@"iconfont-zanting"] forState:UIControlStateNormal];
        [self.stopButton addTarget:self action:@selector(stopButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.hud hide:YES];
       
    } failure:^(NSError *error) {
        self.errorlabel = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH/2-100, HEIGHT/2-15, 0, 30)];
        [self.view addSubview:self.errorlabel];
        self.errorlabel.layer.borderWidth = 1;
        self.errorlabel.layer.cornerRadius = 8;
        self.errorlabel.text =@"网络连接错误! 请检查网络";
        self.errorlabel.font=[UIFont systemFontOfSize:20];
        self.errorlabel.textColor = [UIColor whiteColor];
        self.errorlabel.backgroundColor = [UIColor colorWithRed:0.211 green:0.218 blue:0.225 alpha:1.000];
        self.errorlabel.textAlignment = NSTextAlignmentCenter;
        self.errorlabel.layer.masksToBounds = YES;
        [self.errorlabel sizeToFit];
        
        [self.destCollectionView headerEndRefreshing];
        
        [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(removelabel) userInfo:Nil repeats:NO];
       
        
    }];
   
   
}
-(void)stopButtonClick:(UIButton *)button
{
    if (self.isPlay) {
        [_player stop];
        [self.stopButton setImage:[UIImage imageNamed:@"iconfont-player-play-2"] forState:UIControlStateNormal];
        self.isPlay =NO;
    }
    else
    {
        [self.stopButton setImage:[UIImage imageNamed:@"iconfont-zanting"] forState:UIControlStateNormal];
        [_player play];
        self.isPlay = YES;
    }
    
}

-(void)removelabel
{
    [self.errorlabel removeFromSuperview];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
